package month_03.day24;

import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Demo1 implements Runnable {
    static Demo1 instance=new Demo1();
    static int i=0;
    @Override
    public void run() {
        Thread thread=Thread.currentThread();
        synchronized(instance){
            for (int j = 0; j < 10000; j++) {
                log.info("所属线程组:" + thread.getThreadGroup().getName() + ",线程名称:" + thread.getName()+"数I："+i);
                i++;

            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(instance);
        Thread t2 = new Thread(instance);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(i);
    }
}
